home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 3
/
Amiga Tools 3.iso
/
rexx
/
center.pvrx
< prev
next >
Wrap
Text File
|
1995-03-03
|
3KB
|
132 lines
/* $VER: Center.pvrx 3.0 (26.Jan.94) */
/* This macro will get the coordinates of the center of the
bounding box of all selected objects, and move those objects so
that the new coordinates for the center of the bounding box are the
CENTER OF THE PAGE.
Copyright © 1989-93 by Stylus, Inc.
Author: Jeff Blume & Ross Cunniff
Usage: Assign to Ctrl-Key or RX tool
The macro expects to find at least one selected object. */
/*
call open STDOUT,"RAM:RxOut.txt",W
call open STDERR,"RAM:RxErr.txt",W
trace R
*/
options results
/* Get the argument list to see whether if Ctrl-Key wants explicit "Both" */
arg arglist
Action = word(arglist,1)
/* Try to get exclusive lock on project window.
If can't get lock, not polite to interrupt. */
'Lock Wait'
if rc ~= 0 then exit
/* Get coords of bounding box center */
'SelExtent' Ext
if RC ~= 0 then call ERROR "No object selected!"
CX = (Ext.X1 + Ext.X2) / 2
CY = (Ext.Y1 + Ext.Y2) / 2
'GetPageSize' Pdims
CPX = (Pdims.X2 + Pdims.X1) / 2
CPY = (Pdims.Y2 + Pdims.Y1) / 2
/*
X-Y distance from center from the following:
MX = (CPX - CX); MY = (CPY - CY)
*/
if Action ~= "BOTH" then call Request
/*** If Action = "ACTION" then call Request ***/
/*** then pass Horiz & Vert to...? ***/
select
when Action = "Horizontal" then do
MY = 0 /* Center Horizontal */
MX = (CPX - CX)
end
when Action = "Vertical" then do
MX = 0 /* Center Vertical */
MY = (CPY - CY)
end
when Action = "Origin" then do
MX = -Ext.X1
MY = -Ext.Y1
end
otherwise do
MX = (CPX - CX) /* Center Both */
MY = (CPY - CY)
end
end
'SelectList' Sel; SelN = Result
'PushUndo'
do i = 0 for SelN
'Move' Sel.i MX MY
end
CLEANUP:
'Repair'
'UnLock'
EXIT
ERROR:
arg ErrTxt
'GetBool ErrTxt "Cancel" "Cancel"'
'UnLock'
Exit
REQUEST:
if show("P","REXXREQUEST") then
do
call DefGads
address REXXREQUEST 'GetRequest Gads'; OK=Result
if OK > 0 then /* The user didn't cancel the requester... */
do
Action = Gads.1.Value
Action = Gads.1.Descr.Action
end /* end if do */
else call CleanUp /* User canceled */
end
else call error "No REXXRequest"
return
DEFGADS:
/* Define PubScreen */
Gads.PubScreen = "PROVECTOR"
/* Define Window */
Gads.0.LeftEdge = 166; Gads.0.TopEdge = 70; Gads.0.Width = 324; Gads.0.Height = 50
Gads.0.Label = "Center Selected Objects"
/* Define Cycle Gadget */
Gads.1.LeftEdge = 160; Gads.1.TopEdge = 8; Gads.1.Width = 148; Gads.1.Height = 12
Gads.1.Label = "Center Horiz/Vert"
Gads.1.Type = Cycle
Gads.1.Descr.0 = "Both"
Gads.1.Descr.1 = "Horizontal"
Gads.1.Descr.2 = "Vertical"
Gads.1.Descr.3 = "Origin"
Gads.1.Size = 4
Gads.1.Value = "0" /* initial/default */
/* Set up the OK and CANCEL buttons */
Gads.2.LeftEdge = 16; Gads.2.TopEdge = 28; Gads.2.Width = 64; Gads.2.Height = 12
Gads.2.Type = Button; Gads.2.Label = "OK"; Gads.2.EndGad = 1
Gads.3.LeftEdge = 244; Gads.3.TopEdge = 28; Gads.3.Width = 64; Gads.3.Height = 12
Gads.3.Type = Button; Gads.3.Label = "Cancel"; Gads.3.EndGad = -1
/* Total Gadgets + Window */
Gads.NumGads = 4
return /* return DefGads */